package com.wang.web3.data.service;

import com.wang.web3.data.api.Api;

import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * @author Mr.Wang
 * @version 1.0
 * @time 2016/8/22-13:12
 * @describe
 */
public class Business implements IBusiness {

    static Business mBusiness;

    public static Business getInstance() {
        if (mBusiness == null) {
            mBusiness = new Business();
        }
        return mBusiness;
    }


    Api mIServiceAPI = HttpDao.getInstance().getIServiceAPI();


//    //修改用户信息
//    @Override
//    public void edituserinfo(RequestEditUserInfoBean requestEditUserInfoBean, ICallBackListener mICallBackListener) {
//        mIServiceAPI.edituserinfo(requestEditUserInfoBean.getUid(), requestEditUserInfoBean.getToken(), requestEditUserInfoBean.getFull_name(),
//                requestEditUserInfoBean.getAddress(), requestEditUserInfoBean.getBirthday(), requestEditUserInfoBean.getCity(), requestEditUserInfoBean.getProvince(),
//                requestEditUserInfoBean.getArea(), requestEditUserInfoBean.getZip_code(), requestEditUserInfoBean.getIs_newbie())
//                .subscribeOn(Schedulers.io())
//                // 操作observeOn之后操作主线程中运行.
//                .observeOn(AndroidSchedulers.mainThread())
//                .subscribe(HttpDao.getInstance().createSubscriber(mICallBackListener));
//    }

    @Override
    public void doGirlsTask(String currentTabs, int pageNum, int pageSize, ICallBackListener mICallBackListener) {
        mIServiceAPI.doGirlsTask(currentTabs, pageNum, pageSize)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(HttpDao.getInstance().createSubscriber(mICallBackListener));
    }

    public void doPropsTask(String currentTabs, int pageNum, int pageSize, ICallBackListener mICallBackListener) {
        mIServiceAPI.doPropsTask(currentTabs, pageNum, pageSize)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(HttpDao.getInstance().createSubscriber(mICallBackListener));
    }

    public void doGirlsDetailTask(int girlId, ICallBackListener mICallBackListener) {
        mIServiceAPI.doGirlsDetailTask(girlId)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(HttpDao.getInstance().createSubscriber(mICallBackListener));
    }
}
